import serverRequest from "@/utils/server-request.ts";

export interface ProblemCodeForm {
    problemId: string
    language: number
    mainFunction: string
    userFunction: string
}
export function saveProblemCodeApi(problemCodeForm: ProblemCodeForm) {
    return serverRequest({
        url: '/code',
        method: 'POST',
        data: problemCodeForm
    })
}

export function updateProblemCodeApi(problemCodeForm: ProblemCodeForm) {
    return serverRequest({
        url: '/code',
        method: 'PUT',
        data: problemCodeForm
    })
}

export function getProblemCodeApi(problemId: string, language: number) {
    return serverRequest({
        url: '/code',
        method: 'GET',
        params: {
            problemId: problemId,
            language: language
        }
    })
}

export function removeProblemCodeApi(problemId: string, language: number) {
    return serverRequest({
        url: '/code',
        method: 'DELETE',
        params: {
            problemId: problemId,
            language: language
        }
    })
}